Import the datasets

Data Wrangling

Create neighborhood-level proxies for individual-level covariates.

Select environmental variables

env.sf <- env.sf %>% 
  select(reli, ptot, d_sport, n_acc_ped, green_sp, pm25, no2, noise, env_index, soc_eco_index) %>% 
  rename_at(vars(-reli, -geometry), toupper)

Merge socio-eco and environmental covariates

neighborhood.vd.sf <- env.sf %>%
  inner_join(socdemo, by="reli")

Create a subset for Lausanne’s neighborhoods

Save

st_write(neighborhood.laus.sf, "../processed_data/neighborhood_lausanne.gpkg", delete_dsn = TRUE)
## Deleting source `../processed_data/neighborhood_lausanne.gpkg' using driver `GPKG'
## Writing layer `neighborhood_lausanne' to data source 
##   `../processed_data/neighborhood_lausanne.gpkg' using driver `GPKG'
## Writing 1224 features with 26 fields and geometry type Polygon.

Explore correlations between variables

Pearson’s correlation

Vaud

corr.vd <- compute_corr_matrix(neighborhood.vd.sf %>% st_drop_geometry() %>% select(-c("reli", "POVERTY")))

print_highly_correlated_vars(corr.vd, threshold = 0.7)
##    var1      var2       cor
## 1  PM25       NO2 0.8260655
## 2  PM25 ENV_INDEX 0.8276604
## 3   NO2 ENV_INDEX 0.8847808
## 4 NOISE ENV_INDEX 0.7172373

Lausanne

corr.laus <- compute_corr_matrix(neighborhood.laus.sf %>% st_drop_geometry() %>% select(-c("reli", "POVERTY")))

print_highly_correlated_vars(corr.laus, threshold = 0.7)
##    var1      var2       cor
## 1  PM25       NO2 0.8392251
## 2  PM25 ENV_INDEX 0.8752496
## 3   NO2 ENV_INDEX 0.8124998
## 4 NOISE ENV_INDEX 0.8104564

The same patterns are observed between Vaud state and Lausanne city if we consider a 0.7 threshold.

For socio-demographic / economic characteristics: we keep both the composite index (SOC_ECO_INDEX) and the standalone variables since they seem to bring different informations.
For environmental characteristics: we keep the composite index of environmental exposures (ENV_INDEX) over the air pollution and noise variables due to highly correlated variables. We also consider the population density (PTOT), accessibility to sport facilities (D_SPORT), area’s greenspace (GREEN_SP), and pedestrian accidents (N_ACC_PED) to quantify walkability, housing, and landscape.

Drop air pollutants and noise

neighborhood.vd.sf <- neighborhood.vd.sf %>% select(-c(PM25, NO2, NOISE))
neighborhood.laus.sf <- neighborhood.laus.sf %>% select(-c(PM25, NO2, NOISE))

Explore global and local clustering

Define spatial weights

Distance-based Weights

W.dist <- create_distance_weights(neighborhood.laus.sf, 300)
## Warning: st_centroid assumes attributes are constant over geometries

## Warning: st_centroid assumes attributes are constant over geometries
summary(W.dist$rgeoda)
##                      name             value
## 1 number of observations:              1224
## 2          is symmetric:               TRUE
## 3               sparsity: 0.017058075953693
## 4        # min neighbors:                 0
## 5        # max neighbors:                28
## 6       # mean neighbors:  20.8790849673203
## 7     # median neighbors:                22
## 8           has isolates:              TRUE

Queen Contiguity Weights

W.queen <- create_queen_weights(neighborhood.laus.sf)
summary(W.queen$rgeoda)
##                      name               value
## 1 number of observations:                1224
## 2          is symmetric:                 TRUE
## 3               sparsity: 0.00527307873040284
## 4        # min neighbors:                   0
## 5        # max neighbors:                   8
## 6       # mean neighbors:    6.45424836601307
## 7     # median neighbors:                   7
## 8           has isolates:                TRUE

Global & Local spatial autocorrelation (Moran’s I)

PTOT

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "PTOT", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            826
## 2 HH            128
## 3 LL            207
## 4 LH             47
## 5 HL             15
## 6 Isolated        1
## tmap mode set to plotting

run_spatial_autocorr(W.queen, neighborhood.laus.sf, "PTOT", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS           1023
## 2 HH             73
## 3 LL            111
## 4 LH             10
## 5 HL              1
## 6 Isolated        6
## tmap mode set to plotting

D_SPORT

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "D_SPORT", sectors.laus)
## # A tibble: 2 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 HH           1223
## 2 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "D_SPORT", sectors.laus)

N_ACC_PED

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "N_ACC_PED", sectors.laus)
## # A tibble: 4 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            312
## 2 HH            339
## 3 LL            572
## 4 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "N_ACC_PED", sectors.laus)

GREEN_SP

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "GREEN_SP", sectors.laus)
## # A tibble: 4 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            230
## 2 HH            513
## 3 LL            480
## 4 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "GREEN_SP", sectors.laus)

ENV_INDEX

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "ENV_INDEX", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            547
## 2 HH            316
## 3 LL            314
## 4 LH             28
## 5 HL             18
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "ENV_INDEX", sectors.laus)

SOC_ECO_INDEX

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "SOC_ECO_INDEX", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            965
## 2 HH            134
## 3 LL             77
## 4 LH             23
## 5 HL             24
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "SOC_ECO_INDEX", sectors.laus)

INCOME

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "INCOME", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            959
## 2 HH             79
## 3 LL            129
## 4 LH             25
## 5 HL             31
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "INCOME", sectors.laus)

F_75_MORE

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "F_75_MORE", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS           1137
## 2 HH             17
## 3 LL             53
## 4 LH              9
## 5 HL              7
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "F_75_MORE", sectors.laus)

M_75_MORE

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "M_75_MORE", sectors.laus)
## # A tibble: 2 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS           1223
## 2 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "M_75_MORE", sectors.laus)

SWISS

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "SWISS", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            922
## 2 HH            143
## 3 LL            101
## 4 LH             32
## 5 HL             25
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "SWISS", sectors.laus)

UNEMPLOYMENT

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "UNEMPLOYMENT", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS           1091
## 2 HH             44
## 3 LL             57
## 4 LH             13
## 5 HL             18
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "UNEMPLOYMENT", sectors.laus)

LOW_EDUC

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "LOW_EDUC", sectors.laus)
## # A tibble: 6 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 NS            600
## 2 HH            237
## 3 LL            305
## 4 LH             36
## 5 HL             45
## 6 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "LOW_EDUC", sectors.laus)

HH_1PERS

run_spatial_autocorr(W.dist, neighborhood.laus.sf, "HH_1PERS", sectors.laus)
## # A tibble: 2 × 2
##   lisa_labels `n()`
##   <fct>       <int>
## 1 HH           1223
## 2 Isolated        1
## tmap mode set to plotting

# run_spatial_autocorr(W.queen, neighborhood.laus.sf, "HH_1PERS", sectors.laus)